﻿//===============================================================================
// Copyright (C) 2007-2010  HARBORHOUSEHOME   
// ALL RIGHTS RESERVED
//===============================================================================
// FILENAME : TopDictionary
// DESCRIPTION :
// CREATED BY FETY AT   2010-5-14 15:14:05
//===============================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
///TopDictionary 的摘要说明
/// </summary>
namespace TaobaoAPI
{
    public class TopDictionary:Dictionary<string,string>
    {
        public TopDictionary() { }
        public TopDictionary(IDictionary<string, string> dictionary) : base(dictionary) { }

        public void Add(string key, object value)
        {
            string strValue;
            if (value == null)
            {
                strValue = null;
            }
            else if (value is string)
            {
                strValue = (string)value;
            }
            else if (value is Nullable<int>)
            {
                strValue = (value as Nullable<int>).Value.ToString();
            }
            else if (value is Nullable<long>)
            {
                strValue = (value as Nullable<long>).Value.ToString();
            }
            else if (value is Nullable<DateTime>)
            {
                Nullable<DateTime> dateTime = value as Nullable<DateTime>;
                strValue = dateTime.Value.ToString(Constants.DATE_TIME_FORMAT);
            }
            else if (value is Nullable<double>)
            {
                strValue = (value as Nullable<double>).Value.ToString();
            }
            else if (value is Nullable<bool>)
            {
                strValue = (value as Nullable<bool>).Value.ToString();
            }
            else
            {
                strValue = value.ToString();
            }
        }

        private new void Add(string key,string value)
        {
            if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
            {
                base.Add(key, value);
            }
        }
    }
}
